/**
 * 
 */
package ve.com.neometrica.inventario.impl.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import ve.com.neometrica.inventario.api.dao.MarcaDao;
import ve.com.neometrica.inventario.api.model.Marca;

/**
 * @author a.cabrera
 *
 */
public class MarcaDaoImpl extends HibernateDaoSupport implements MarcaDao {

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.MarcaDao#getAll()
	 */
	@Override
	public List<Marca> getAll() {
		return getHibernateTemplate().loadAll(Marca.class);
	}

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.MarcaDao#save(ve.com.neometrica.inventario.api.model.Marca)
	 */
	@Override
	public void save(Marca marca) {
		if(marca.getId()==null){
			this.getHibernateTemplate().save(marca);
		}else{
			this.getHibernateTemplate().saveOrUpdate(marca);
		}

	}

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.MarcaDao#getById(java.lang.Integer)
	 */
	@Override
	public Marca getById(Integer id) {
		return getHibernateTemplate().load(Marca.class, id);
	}

}
